package com.wyh.utils.sqlUtils.activity;

import com.wyh.entity.Activity;

import javax.validation.constraints.Negative;
import javax.validation.constraints.NotNull;


public class findActivitySqlDynamic{
    public String findDynamic(@NotNull Activity activity) {
        String sql = "select * from activity where ";
        if (activity.getId() != 0 && activity.getName() != null){
            sql += " id = " + activity.getId() + " and name = '" + activity.getName() + "'";
        }
        else {
            if (activity.getId() != 0) {
                sql += " id = " + activity.getId();
            }
            if (activity.getName() != null && !activity.getName().equals("")) {
                sql += "  name = '" + activity.getName() + "'";
            }
        }

        return sql;
    }
}
